package com.interwater.coffeecoupon.base;

import android.util.Log;
import android.webkit.ConsoleMessage;
import android.webkit.ConsoleMessage.MessageLevel;
import android.webkit.WebChromeClient;
import android.webkit.WebView;

/**
 * javascrip native call 을 위한 method 정의 
 * @author user
 *
 */
public class NativeCall {
	public NativeCall(WebView webView){
		webView.setWebChromeClient(new WebChromeClient(){
			@Override
			public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
				final MessageLevel level = consoleMessage.messageLevel();
				switch (level) {
				case TIP:
				case DEBUG:
					Log.d("console", "line : " + consoleMessage.lineNumber()
							+ ", src : " + consoleMessage.sourceId()
							+ ", msg : " + consoleMessage.message());
					break;
				case LOG:
					Log.i("console", "line : " + consoleMessage.lineNumber()
							+ ", src : " + consoleMessage.sourceId()
							+ ", msg : " + consoleMessage.message());
					break;
				case ERROR:
					Log.e("console", "line : " + consoleMessage.lineNumber()
							+ ", src : " + consoleMessage.sourceId()
							+ ", msg : " + consoleMessage.message());
					break;
				case WARNING:
					Log.w("console", "line : " + consoleMessage.lineNumber()
							+ ", src : " + consoleMessage.sourceId()
							+ ", msg : " + consoleMessage.message());
					break;
				default:
					Log.d("console", "line:" + consoleMessage.lineNumber()
							+ ", src : " + consoleMessage.sourceId()
							+ ", msg : " + consoleMessage.message());
					break;
				}
				return true;
			}
		});
	}
	
	// 잡다한 log 를 찍어 주자.
}
